EMYOLO=emyolo
EMGETIP=emgetip
EMSETTEMPIP=emsettempip
EMSETIP=emsetip


# GeForce RTX 2080 Ti, RTX 2080, RTX 2070, Quadro RTX 8000, Quadro RTX 6000, Quadro RTX 5000, Tesla T4, XNOR Tensor Cores
ARCH= -gencode arch=compute_75,code=[sm_75,compute_75]

# Jetson XAVIER
# ARCH= -gencode arch=compute_72,code=[sm_72,compute_72]

# yolo
LIBYOLOV4SO=./lib/yolo/libdarknet.so

# EM x64
LIBMVSO=./lib/mv/x64/libMVGev.so

# EM arm64
#LIBMVSO=./lib/mv/arm64/libMVGev.so

DIR_YOLO_INCLUDE=./include/yolo
DIR_MV_INCLUDE=./include/mv

COMMON= -Iinclude/ -I3rdparty/stb/include -DOPENCV -DGPU -I/usr/local/cuda/include/ -DCUDNN -DCUDNN_HALF `pkg-config --cflags opencv4 2> /dev/null || pkg-config --cflags opencv`
CFLAGS=-Wall -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas -fPIC -Ofast -DOPENCV -DGPU -DCUDNN -I/usr/local/cudnn/include/ -DCUDNN_HALF
LDFLAGS= -lm -pthread `pkg-config --libs opencv4 2> /dev/null || pkg-config --libs opencv` -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand -L/usr/local/cudnn/lib64 -lcudnn
	
all: $(EMYOLO) $(EMGETIP) $(EMSETTEMPIP) $(EMSETIP)

$(EMYOLO): 
	g++ -std=c++11 $(COMMON) $(CFLAGS) -o $@ src/yolo_mv.cpp $(LDFLAGS) -L ./ -l:$(LIBYOLOV4SO) -l:$(LIBMVSO)  -I$(DIR_YOLO_INCLUDE) -I$(DIR_MV_INCLUDE)

$(EMGETIP):
	g++ -std=c++11 -o $@ src/EMGetIP.cpp -L ./ -l:$(LIBMVSO) -I$(DIR_MV_INCLUDE)

$(EMSETTEMPIP):
	g++ -std=c++11 -o $@ src/EMSetTempIP.cpp -L ./ -l:$(LIBMVSO) -I$(DIR_MV_INCLUDE)

$(EMSETIP):
	g++ -std=c++11 -o $@ src/EMSetIP.cpp -L ./ -l:$(LIBMVSO) -I$(DIR_MV_INCLUDE)

.PHONY: clean

clean:
	rm -rf $(EMYOLO) $(EMGETIP) $(EMSETTEMPIP) $(EMSEIP)